import datetime

from k3_data_report.business.cgtj_db import Cgtj
from k3_data_report.business.config import bussiness_cal_fields
from k3_data_report.business.yjdh_db import Yjdh

__author__ = "Ypf"
_date_ = "2019/9/12-10:40"
fist = datetime.date(datetime.date.today().year, datetime.date.today().month , 1)
last = datetime.date(datetime.date.today().year, datetime.date.today().month+1, 1) - datetime.timedelta(1)
time1=str(fist)[0:7]
print (time1)

def yjdh():
    time1=str(fist)[0:7]
    db_sql = bussiness_cal_fields['k3_caozuo']
    check_sql = db_sql["insert_check_sql"] % ('zjzhmx', time1)
    check_dic = Cgtj.check_cf(check_sql)
    if len(check_dic) == 0:
        sql = db_sql['yjdh_sql']
        db_insert_sql = db_sql['yjdh_insert_sql']
        Yjdh.get_yjdh(sql, db_insert_sql, time1)
    else:
        print("该月份数据已经插入请更换月份")